// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
// import vuePicturePreview from 'vue-picture-preview'
import vuePicturePreview from './components/preview'
import Mint from 'mint-ui'
import 'mint-ui/lib/style.css'
import registComponents from './regist-components'
import VueClipboard from 'vue-clipboard2'
import * as filters from '../src/filters'
import * as request from '../src/request/pat'
import * as utils from '../src/utils'
import axios from 'axios'
// import Vconsole from 'vconsole'
require('babel-polyfill')

Vue.use(Mint)
Vue.use(vuePicturePreview)
Vue.use(VueClipboard)
registComponents(Vue)

// let vConsole = new Vconsole()
// export default vConsole
// 开启小控制台，方便手机查看
// require('vconsole')

let getConfigJson = function () {
  return axios.get('serverconfig.json').then((result) => {
    window.localStorage.setItem('proxyHost', result.data.ApiUrl)
  }).catch(() => {
    window.localStorage.setItem('proxyHost', 'http://192.168.254.58:8888')
  })
}

async function init () {
  console.log('11111111111')
  await getConfigJson()
  console.log('222222222')
  new Vue({ // eslint-disable-line
    el: '#app',
    router,
    components: {App},
    template: '<App/>'
  })
}
init()
// 挂载全局参数与方法
Vue.prototype.$request = request
Vue.prototype.$utils = utils

Vue.config.productionTip = false
require('./assets/less/style.less')
// 实例化Vue的filter
Object.keys(filters).forEach(k => Vue.filter(k, filters[k]))

/* eslint-disable no-new */
